<template>
  <h2>依赖注入 - {{ count }}</h2>
  <button @click="fn">btn</button>
  <child></child>
</template>

<script>
import { ref, provide } from "vue";
import Child from "./10-Inject.vue";
export default {
  components: {
    Child,
  },
  setup() {
    const count = ref(10);

    // provide也是函数调用
    // 里面是两个参数, 分别是key和value
    provide("count", count);

    const fn = () => {
      count.value++;
    };

    return {
      count,
      fn,
    };
  },
};
</script>
